home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / exbine.zip / BINED.HDR < prev    next >
Text File  |  1993-01-04  |  6KB  |  166 lines

  1. {$I-}
  2. {$S-}
  3. {$R-}
  4.  
  5. unit BinEd;
  6.   {-The Borland binary editor interface for Turbo Pascal}
  7.  
  8. interface
  9.  
  10. const
  11.   MaxFileSize = $FFE0;      {Maximum editable file size }
  12.   EdOptInsert = $1;         {Insert on flag}
  13.   EdOptIndent = $2;         {Autoindent on flag}
  14.   EdOptTAB = $8;            {Tab on flag}
  15.   EdOptBlock = $10;         {Show marked block}
  16.   EdOptNoUpdate = $20;      {Don't update screen when entering editor}
  17.   EventKBflag = 1;          {Scroll, num or caps locks modified mask}
  18.   CAnorm = #255#1;          {Activates CRT "normal" attribute}
  19.   CAlow = #255#2;           {Activates CRT "low"        -    }
  20.   CAblk = #255#3;           {Activates CRT "block"      -    }
  21.   CAerr = #255#4;           {Activates CRT "error"      -    }
  22.   EdStatTextMod = 1;        {Text buffer modified mask}
  23.  
  24. type
  25.   AttrArray = array[0..3] of Byte;
  26.   ASCIIZ = array[0..255] of Char;
  27.   ASCIIZptr = ^ASCIIZ;
  28.   TextBuffer = array[0..$FFF0] of Char;
  29.  
  30.   CRTinsStruct =            {CRT installation structure}
  31.   record
  32.     CRTtype : Byte;         {1=IBM, 0=Non}
  33.     CRTx1, CRTy1,
  34.     CRTx2, CRTy2 : Byte;    {Initial window size}
  35.     CRTmode : Byte;         {Initial mode 0-3,7 or FF(default)}
  36.     CRTsnow : Byte;         {0 if no snow, don't care for mono}
  37.     AttrMono : AttrArray;   {CRT attributes for mono mode}
  38.     AttrBW : AttrArray;     {CRT attributes for b/w modes}
  39.     AttrColor : AttrArray;  {CRT attributes for color modes}
  40.   end;
  41.   CIptr = ^CRTinsStruct;
  42.  
  43.   EdInsStruct =             {Command table installation structure}
  44.   record
  45.     ComTablen : Word;       {Maximum length of command table}
  46.     ComTab : TextBuffer;    {Command table}
  47.   end;
  48.   EIptr = ^EdInsStruct;
  49.  
  50.   MIinsStruct =             {Main installation structure}
  51.   record
  52.     Ver : Byte;             {Main version}
  53.     VerSub : Byte;          {Sub version}
  54.     VerPatch : Char;        {Patch level}
  55.     CPUmhz : Byte;          {CPU speed for delays}
  56.     CIstruct : CIptr;       {Points to CRT installation record}
  57.     EIstruct : EIptr;       {Points to Editor installation area}
  58.     DefExt : ASCIIZptr;     {Points to ASCIIZ default extension}
  59.   end;
  60.   MIptr = ^MIinsStruct;
  61.  
  62.   EdCB =                    {Editor control block in detail}
  63.   record
  64.     x1, y1, x2, y2 : Byte;  {UL & LR corners of editor window}
  65.     DataSeg : Word;         {Segment address of editor data area}
  66.     DataSegLen : Word;      {Requested data area length (bytes)}
  67.     Options : Word;         {Bit flags for editor options}
  68.     FileStr : ASCIIZptr;    {Points to ASCIIZ filename}
  69.     Commands : ASCIIZptr;   {Points to string of editor commands}
  70.     Place1 : ASCIIZptr;     {Not used here}
  71.     Place2 : ASCIIZptr;     {Not used here}
  72.     Event : Pointer;        {Points to event handling procedure}
  73.     Buffer : ^TextBuffer;   {Points to text area}
  74.     BufSize : Word;         {Available size for text}
  75.     MIstruct : MIptr;       {Points to main installation record}
  76.     ComTab : ASCIIZptr;     {Points to terminate command table}
  77.     EOtext : Word;          {Current number of chars in text buffer}
  78.     CursorPos : Word;       {Current cursor position in buffer}
  79.     BlockStart : Word;      {Start of marked block in buffer}
  80.     BlockEnd : Word;        {End of marked block in buffer}
  81.     Status : Word;          {Editor status}
  82.     DataPtr : ^TextBuffer;  {Points to Turbo heap block  }
  83.   end;                      {  allocated for text buffer}
  84.  
  85. const
  86.   {CRT attributes for   normal low blk error}
  87.   MonoArray : AttrArray = ($F, $7, $7, $70);
  88.   BwArray : AttrArray = ($F, $7, $7, $70);
  89.   ColorArray : AttrArray = ($E, $7, $3, $1E);
  90.  
  91.   {-----------------------------------------------------------------}
  92.  
  93. procedure CRTputFast(x, y : Word; s : string);
  94.   {-Use binary editor services to write a string to the screen}
  95.   {x in 1..25, y in 1..80}
  96.  
  97. function ExpandPath(Fname : string) : string;
  98.   {-Return a complete path using the binary editor services}
  99.  
  100. function InitBinaryEditor(
  101.     var EdData : EdCb;         {Editor control block}
  102.     DataLen : Word;            {Size of binary editor workspace}
  103.     Cx1 : Byte;                {Editor window, upper left x 1..80}
  104.     Cy1 : Byte;                {Editor window, upper left y 1..25}
  105.     Cx2 : Byte;                {Editor window, lower right x 1..80}
  106.     Cy2 : Byte;                {Editor window, lower right y 1..25}
  107.     WaitForRetrace : Boolean;  {True for snowy color cards}
  108.     Coptions : Word;           {Initial editor options}
  109.     DefExtension : string;     {Default file extension  } 
  110.                                {  (must start with a period)!}
  111.     var ExitCommands;          {Commands to exit editor}
  112.     UserEventProcPtr : Pointer {Pointer to user event handler}
  113.     ) : Word;
  114.  
  115.   {-Initialize the binary editor, returning a status code}
  116.   {
  117.   Status Codes -
  118.   0 = Successful initialization
  119.   1 = Insufficient memory space for text buffer
  120.   }
  121.  
  122. function ReadFileBinaryEditor(var EdData : EdCb;
  123.                                   Fname  : string) : Word;
  124.   {-Read a file into the binary editor buffer space, }
  125.   { returning a status code }
  126.   {
  127.   Status codes -
  128.     0 = Successful read
  129.     1 = File not found, new file assumed
  130.     2 = File too large to edit
  131.   }
  132.  
  133. procedure ResetBinaryEditor(var EdData : EdCb);
  134.   {-Call the editor reset procedure}
  135.  
  136. function UseBinaryEditor(var EdData        : EdCb;
  137.                              StartCommands : string) : Integer;
  138.   {-Edit file, using startcommands, and returning an exitcode}
  139.   {
  140.   Exit codes -
  141.    -1 = Editing terminated with ^KD
  142.     0 = Editing terminated with first user-specified exit command
  143.     1 ...
  144.   }
  145.  
  146. function ModifiedFileBinaryEditor(var EdData : EdCb) : Boolean;
  147.   {-Return true if text buffer was modified during edit}
  148.  
  149. function FileNameBinaryEditor(var EdData : EdCb) : string;
  150.   {-Return the current file pathname of the specified control block}
  151.  
  152. function SaveFileBinaryEditor(var EdData     : EdCb;
  153.                                   MakeBackup : Boolean) : Word;
  154.   {-Save the current file in the editor text buffer,
  155.   {  returning a status code }
  156.   {
  157.   Status codes -
  158.     0 = Successful save
  159.     1 = File creation error
  160.     2 = Disk write error
  161.     3 = Error closing file
  162.   }
  163.  
  164. procedure ReleaseBinaryEditorHeap(var EdData : EdCb);
  165.   {-Release heap space used by a binary editor control block}
  166.